package com.gdcp.rv;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;

public class Add_Student extends AppCompatActivity {
        private Button add_btn;
        private EditText add_name;
        private EditText add_age;
        private RadioButton img1;
        private RadioButton img2;
        private RadioButton img3;
        private int imgId;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add__student);

        initBundle();
        add_btnEvent();
    }


    //点击事件
    private void add_btnEvent() {
        add_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (img1.isChecked()){
                    imgId=R.drawable.dog1;
                }
                else if(img2.isChecked()){
                    imgId=R.drawable.dog2;
                }
                else if(img3.isChecked()){
                    imgId=R.drawable.dog3;
                }
                Intent intent = new Intent();
                intent.putExtra("NAME",add_name.getText().toString());
                intent.putExtra("AGE",Integer.parseInt((add_age.getText().toString())));
                intent.putExtra("ID",imgId);
                setResult(2008,intent);
                finish();
            }
        });


    }



    //绑定捆件

    @SuppressLint("ResourceType")
    private void initBundle() {
        add_btn=findViewById(R.id.add_btn);
        add_age=findViewById(R.id.add_age);
        add_name=findViewById(R.id.add_name);
        img1=findViewById(R.id.img1);
        img2=findViewById(R.id.img2);
        img3=findViewById(R.id.img3);
    }




}
